package com.ossjk.oa.accounting.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.ossjk.oa.accounting.entity.CwCapitals;
import com.ossjk.oa.accounting.vo.MonthFinanceVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface MonthFinanceMapper  extends BaseMapper<CwCapitals> {

//    按类型和月份来查询所有收入支出

    List selectIncome(@Param("ew") Wrapper wapper);
    List selectByDepartment(@Param("ew") Wrapper wapper);

    MonthFinanceVo selectByfenlei(@Param("ew") Wrapper wapper);

    List selectSrZc(@Param("year") Integer year);

    List selectGR(@Param("ew") Wrapper wapper);

    @Select("select   left(max(wagemonth),7) from cw_salary where wagemonth<(select min(wagemonth) from cw_salary where left(wagemonth,7) = #{mth}) order by wagemonth desc")
    String selectPreMth(String mth);

    @Select("select   left(min(wagemonth),7) from cw_salary where wagemonth>(select max(wagemonth) from cw_salary where left(wagemonth,7) = #{mth}) order by wagemonth")
    String selectNextMth(String mth);

    @Select("select a.cptMth  from (select DISTINCT left(wagemonth,7) as cptMth  from   cw_salary ) a where  a.cptMth >#{mth} order by a.cptMth desc limit 0,12")
    String[] selectMax12Mth(String mth);

    @Select("select  SUM(IF(cptacount>=0, cptacount,0))as maxMoney from cw_capitals GROUP BY  SUBSTR(cptdate,1,7)")
    Integer[] selectMaxMoney();
}
